package com.focus.wecenter.dao.impl;

import com.focus.wecenter.dao.UserDao;
import com.focus.wecenter.pojo.User;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 用户Dao实现类
 *
 * @author Lv Jing
 * @date 2018年01月05日 13:02
 */
@Repository
public class UserDaoImpl extends BaseDaoImpl<User> implements UserDao {

    @Override
    public User findUserByUsername(String username) {
        List<?> list = this.getHibernateTemplate().find("from User where username = ?", username);
        if (list != null && list.size() > 0) {
            return (User) list.get(0);
        } else {
            return null;
        }
    }

    @Override
    public User findUserByEmail(String email) {
        List<?> list = this.getHibernateTemplate().find("from User where email = ?", email);
        if (list != null && list.size() > 0) {
            return (User) list.get(0);
        } else {
            return null;
        }
    }
}
